﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DayAtTheRaces
{
    public class Guy
    {
        public string Name; // The guy's name
        public Bet MyBet; // An instance of the Bet that has his bet
        public int Cash; // How much cash he has

        // The last two fields are the guy's GUI controls on the form
        public RadioButton MyRadioButton; // My RadioButton
        public Label MyLabel; // My Label

        public void UpdateLabels()
        {
            // Set my label to my bet's description, and the label on my
            // radio button to show my cash ("Joe has 43 bucks")
            this.MyRadioButton.Text = this.Name + " has " + this.Cash + " bucks";
            this.MyLabel.Text = this.MyBet.GetDescription();
                        
        }

        public void ClearBet()
        {
            // Reset my bet so it's zero
            MyBet.Amount = 0;
            MyRadioButton.Text = this.Name + " has " + this.Cash + " bucks"; // update cash 
            MyLabel.Text = this.Name + " hasn't placed a bet"; // reset to no bet placed
        }

        public bool PlaceBet(int Amount, int Dog)
        {
            // Place a new bet and store it in my bet field (Remember bets are represented by instances of Bet)
            MyBet = new Bet();
            this.MyBet.Amount = Amount;
            this.MyBet.Dog = Dog;
            // Return true if the guy had enough money to bet
            if (this.MyBet.Amount > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public void Collect(int Winner)
        {
            // Ask my bet to pay out
            // (The key here is to use the Bet object... Let it do the work.)
            this.Cash += this.MyBet.PayOut(Winner);
        }
    }
}
